/*
 * Copyright (c) 2009, artur
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * /kiddie/boot/include/platformjack.h
 * created: Jun 24, 2009
 *
 */


#ifndef _PLATFORMJACK_H_
#define _PLATFORMJACK_H_

#include <multiboot.h>

typedef struct cpu_id
{
	union
	{
		struct
		{
			unsigned int f_stepping :4; /* stepping */
			unsigned int f_model :4; /* model */
			unsigned int f_family :4; /* family */
			unsigned int f_type :2; /* type */
			unsigned int f_model_ext :4;
			unsigned int f_family_ext :8; /* extended family */
		} features;
		unsigned int features_raw;
	};
	unsigned int tlb_info;
	unsigned int serial;
	unsigned int ext_features;
	char vendor[13];
} cpu_id_t;

typedef enum {
	MEM_ZONE_HW = 0,
	MEM_ZONE_KERN,
	MEM_ZONE_OTHER,
	NUM_ZONES
} m_zone_t;

/**
 * Memory descriptor
 */
struct hw_mem {
	unsigned int type;		/* memory type id, ex. RAM, ROM or unavailable (reserved) */
	unsigned long start;	/* linear address of memory */
	unsigned long size;		/* size of memory in bytes */
};
/**
 * Hardware platform profile structure
 */
struct hw_profile {
	unsigned long flags;
	cpu_id_t cpuid;
	struct hw_mem bootmem;		/* kernel work memory */
	char *cmdline;
	multiboot_info_t * mbi;
};

typedef struct hw_profile hw_profile_t;

void update_cpuid(void);
struct cpu_id *get_cpuid(void);

#ifdef USE_PLATFORM_JACK
void __arch_setup_hw_profile(void);

/* arch wrappers */
void __arch_scroll(void);
void __arch_putchar(char);
void __arch_cls(void);

void __arch_interrupt_received_notify (unsigned int);
void __arch_interrupt_init(void);
void __arch_cpu_init(void);
/* void __arch_task_switch (struct object *prev, struct object *next); */
/*
int __arch_task_init(struct object *_newtsk, unsigned int _kstack, unsigned int _ustack,
		void (*task_entry)(void),void *task_params, int __pl);
*/
/* upstream wrappers */
/* void __up_interrupt_handler (struct cpu_regs *regs); */
#endif

#endif /* _PLATFORMJACK_H_ */
